<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="webshop.Cart"%>
<%@page import="database.DBConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../Login/checkLogin.jsp" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../CSS/frontend.css"/>
        <%
            DBConnector dbc = DBConnector.getDBC();
            Cart cart = (Cart) session.getAttribute("CART");
            ArrayList<String[]> cartList = cart.getCart();
        %>
    </head>
    <body>
        <div id="main">
            <jsp:include page="topBar.jsp"></jsp:include>
                <div id="content">
                <%
                    for (int i = 0; i < cartList.size(); i++) {
                        String pid = cartList.get(i)[0];
                        int quantity = Integer.parseInt(cartList.get(i)[1]);
                        ResultSet rs = dbc.doQuery("SELECT productName, salesPrice, Description FROM products WHERE productID = '"+ pid +"'");
                        while (rs.next()) {
                            String name = rs.getString(1);
                            int price = Integer.parseInt(rs.getString(2));
                            String description = rs.getString(3);
                %>
                <div id="product" >
                    <% out.print(name);%>  <br>
                    Varernummer: <%out.print(pid);%><br>
                    <%out.print(description);%><br>
                    Antal: <%out.print(quantity);%><br>
                    Pris: <%out.print(price * quantity);%><br>

                </div>
                <% }
                    }%>
            </div>
            <jsp:include page="footNote.jsp"></jsp:include>
        </div>   
        <br><br>
    </body>
</html>
